﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Epona.Domain.Query.Impl
{
    public class BetweenCriterion : BasicCriterion
    {
        public IComparable From { get; private set; }
        public IComparable To { get; private set; }

        public BetweenCriterion(string propName, IComparable from, IComparable to)
            : base(propName)
        {
            this.From = from;
            this.To = to;
        }

        public override string ToQueryString()
        {
            return string.Format("{0} between {1} and {2}",
                          GetPropNameWithAlias(),
                          GetParamNameWithColon() + "_from",
                          GetParamNameWithColon() + "_to");
        }

        public override NamedParameters GetParameters()
        {
            return NamedParameters.Create()
                .Add(GetParamName() + "_from", From)
                .Add(GetParamName() + "_to", To);
        }
    }
}
